home *** CD-ROM | disk | FTP | other *** search
-
- /***************************************************************************
-
- X4MERSC.C
-
- - code for inline resource trees
-
- Code from:
- FIXTREE - by Guy L. Albertelli
- 4142 Highland Dr.
- Mogadore, Oh. 44260
-
- 01/24/88 created
-
- 05/18/88 22:00
-
- ***************************************************************************/
-
- #define LONG long
- #define WORD int
- #define BYTE char
-
- #include <gemdefs.h>
- #include <obdefs.h>
-
- #include "x4merII2.rsh"
-
- extern WORD global[];
-
- /****************************************************************/
- /* This routine does the equivalent of a rscr_load() and fixup */
- /****************************************************************/
- fix_tree()
- {
- WORD num = NUM_TREE;
- LONG *pl;
- WORD i,j;
-
- pl = (LONG *)&global[5];
- *pl = (LONG)rs_trindex;
-
- for (i=0;i<num;i++)
- {
- j = rs_trindex[i]; /* get index of top obj in tree */
- rs_trindex[i] = (LONG)&rs_object[j];
- fix_object(i,j,j); /* fix top object then all rest */
- fix_level(i,rs_object[j].ob_head,rs_object[j].ob_tail,j);
- }
- }
-
- /****************************************************************/
- /* This routine will clear the pointer to the resource */
- /* tree so that GEM doesn't try to free the memory */
- /****************************************************************/
- unfix_tree()
- {
- LONG *pl;
- pl = (LONG *) &global[5];
- *pl = 0L;
- }
-
- /****************************************************************/
- /* This routine will cycle across a level in the resource */
- /* tree and fix each object in that level. After fixing */
- /* up the object, it will use itself (recursion) to fix */
- /* any objects on a level below. */
- /* */
- /* INPUT: */
- /* tr_x index in rs_trindex of the tree being done */
- /* needed by fix_object */
- /* h object number within tree of first item in */
- /* this level */
- /* t object number within tree of last item in */
- /* this level */
- /* item in tree */
- /****************************************************************/
- fix_level(tr_x,h,t,to)
- WORD tr_x,h,t,to;
- {
- WORD i,nh,nt;
-
- if(h==-1 && t==-1)
- return; /* nobody on this level */
- do
- {
- i = to + h;
- fix_object(tr_x,i,to); /* fix this object up */
- nh = rs_object[i].ob_head; /* get next head */
- nt = rs_object[i].ob_tail; /* and tail indexes */
- fix_level(tr_x,nh,nt,to); /* then fix the next level down */
- h = rs_object[i].ob_next; /* go to next obj on this level */
- } while(t+to!=i); /* till we have done the tail item */
- }
-
- /****************************************************************/
- /* This routine will fix up the pointers in each object */
- /* and any associated control blocks. It will then use */
- /* rsrc_obfix to update the pixel information to adjust */
- /* for the current resolution and display format. */
- /* */
- /* INPUT: */
- /* tr_x index in rs_trindex of the tree being done */
- /* needed by rsrc_obfix */
- /* i object number within rs_object to fixup */
- /* to object number within rs_object of tree top */
- /****************************************************************/
- fix_object(tr_x,i,to)
- WORD tr_x,i,to;
- {
- WORD k;
- LONG tst;
-
- tst = (LONG)rs_object[i].ob_spec; /* get current ob_spec value */
- k = (WORD) tst;
-
- switch(rs_object[i].ob_type)
- { /* handle things depending on type */
-
- case G_TEXT:
- case G_BOXTEXT:
- case G_FTEXT:
- case G_FBOXTEXT:
- if (tst!=-1L)
- {
- rs_object[i].ob_spec = (char *) &rs_tedinfo[k];
- rs_tedinfo[k].te_ptext =
- rs_strings[(int)(rs_tedinfo[k].te_ptext)];
- rs_tedinfo[k].te_ptmplt =
- rs_strings[(int)(rs_tedinfo[k].te_ptmplt)];
- rs_tedinfo[k].te_pvalid =
- rs_strings[(int)(rs_tedinfo[k].te_pvalid)];
- }
- break;
- case G_BUTTON:
- case G_STRING:
- case G_TITLE:
- if (tst!=-1L) {
- rs_object[i].ob_spec =
- rs_strings[k];
- }
- break;
- case G_ICON:
- if (tst!=-1L)
- {
- rs_object[i].ob_spec =
- (char *) &rs_iconblk[k];
- rs_iconblk[k].ib_pmask=
- rs_imdope[(int)(rs_iconblk[k].ib_pmask)].image;
- rs_iconblk[k].ib_pdata=
- rs_imdope[(int)(rs_iconblk[k].ib_pdata)].image;
- rs_iconblk[k].ib_ptext =
- rs_strings[(int)(rs_iconblk[k].ib_ptext)];
- }
- break;
- case G_IMAGE:
- if (tst!=-1L)
- {
- rs_object[i].ob_spec =
- (char *) &rs_bitblk[k];
- rs_bitblk[k].bi_pdata=
- rs_imdope[(int)(rs_bitblk[k].bi_pdata)].image;
- }
- break;
- case G_BOX:
- case G_IBOX:
- case G_BOXCHAR:
- break;
- }
- rsrc_obfix(rs_trindex[tr_x],i-to); /* fix pixel values for rez */
- }
-